<#include "/common/taglibs.ftl" />
<@menu code='${entityName!}'/>
<title><@spring.message code="group"/><@spring.message code="auth"/> - <@spring.message code="${op}" /></title>
<div class="m-portlet">
    <div class="m-portlet__head">
        <div class="m-portlet__head-caption">
            <div class="m-portlet__head-title">
                <span class="m-portlet__head-icon">
                    <i class="flaticon-calendar"></i>
                </span>
                <h3 class="m-portlet__head-text m--font-primary">
                    <@spring.message code="group"/><@spring.message code="auth"/> / <@spring.message code="${op}" />
                    <#if op != 'op.view'>
                    （<@spring.message code="reuqired.tips"/>）
                    </#if>
                </h3>
            </div>
        </div>
        <@formHeaderButtons resourceIdentity='${resourceIdentity!}' baseUrl='${baseUrl!}'/>
    </div>
    <!--begin::Form-->
    <form class="m-form m-form--fit m-form--label-align-right" method="post" id="mainForm">
        <div class="m-portlet__body">
            <div class="m-form__content">
                <@showFieldErrors commandName="m" />
                <#include "/common/taglibs/validationMessage.ftl">
            </div>
            <div class="m-form__section m-form__section--first">
                <div class="m-form__heading">
                    <h3 class="m-form__heading-title"><@spring.message code="group"/></h3>
                </div>
                <div class="form-group m-form__group row">
                    <label class="col-form-label col-lg-3 col-sm-12"><@spring.message code="group"/></label>
                    <div class="col-lg-4 col-md-9 col-sm-12">
                        <#if op == 'op.add'>
                            <select id="group-select" name="groupIds" class="form-control m-select2" multiple>
                            </select>
                        <#else>
                            <p class="form-control-static"> <a class="btn m-btn btn-outline-info btn-sm">${(group.name)!'Not found'}</a> </p>
                            <input type="hidden" name="groupId" value="${(m.groupId)!}"/>
                        </#if>
                    </div>
                </div>
            </div>
            <div class="m-form__seperator m-form__seperator--dashed"></div>
            <#include "/system/auth/role_permission.ftl" />
        </div>
        <@formFooterButtons resourceIdentity='${resourceIdentity!}' baseUrl='${baseUrl!}'/>
    </form>
    <!--end::Form-->
</div>
<page-plugin-style>
<#include "/common/plugins/bootstrap.duallistbox.style.ftl" />
<#include "/common/plugins/jquery.ztree.style.ftl" />
</page-plugin-style>
<page-plugin-script>
<#include "/common/plugins/bootstrap.duallistbox.script.ftl" />
<#include "/common/plugins/jquery.ztree.script.ftl" />
</page-plugin-script>
<page-style>
</page-style>
<page-script>
	<script>
        jQuery(document).ready(function() {
            var $form = $("#mainForm")
            <#if op == 'op.add'>
                $.m.form.initSelect($('#group-select'), {
                    ajax : {
                        url : "${ctx}/system/group/ajax/select/search"
                    }
                });
            </#if>
            $.m.form.validate($form, {
                rules: {
                    groupIds: {
                        required: true
                    }
                }
            });
                $.m.system.auth.initSelectRole([${(m.roleIds)!?join(',')}]);
                $.m.system.auth.initSelectPermission();
            <#if op == 'op.view'>
                $("#roleIds").prev(".bootstrap-duallistbox-container").find("button").attr("disabled", "disabled");
                $.m.form.readonly($form, false);
            </#if>
        });
	</script>
</page-script>